<?php //echo '<pre>';die(print_r($place));?>
<script type="text/javascript" 
src="http://maps.googleapis.com/maps/api/js?sensor=false&language=vi"></script>
<script type="text/javascript">
$(function(){
    
    initialize();
});
var map;
function initialize() {
    <?php foreach($place AS $els=>$le):?>
        var myLatlng<?php echo $els?> = new google.maps.LatLng(<?php echo $le->lat?>,<?php echo $le->long?>);
    <?php endforeach;?>
    
    var myOptions = {
        zoom: 13,
        center: myLatlng<?php echo ceil($els/2);?>,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    map = new google.maps.Map(document.getElementById("div_id"), myOptions); 
    
    <?php foreach($place AS $el=>$le):?>
    
    //var text<?php echo $el?> = '<h5><b>Chiến dịch tại điểm này: </b></h5>';
    var text<?php echo $el?> = '<h5 style="line-height: 10px;"><u><?php echo $le->address;?> </u></h5>Trạng thái: <?php echo $le->status_modem;?> <br/>RAM: <?php echo $le->info_ram ? number_format(floatval($le->info_ram),2).'%' : 'Đang cập nhật';?><br/>CPU: <?php echo $le->info_cpu ? number_format(floatval($le->info_cpu),2).'%' : 'Đang cập nhật';?><br/>Số người truy cập: <?php echo $le->info_users;?><br/>';
    <?php if(!in_array($le->campaign, array(null, '', '0'))):?>
    <?php foreach($le->campaign AS $ell=>$eel):?>
    text<?php echo $el?> += "<?php echo ($ell+1).': '?><a onclick='showPreload()' href='<?php echo $baseurl.'statistic-user.html?p_id='.$eel->encode_pid.'&c_id='.$eel->encode_cid?>' ><b style='color:#737e86'><?php echo $eel->title ?></b></a> <br />";
    <?php endforeach;?>
    <?php else:?>
    text<?php echo $el?> += '- Không có';
    <?php endif;?>
    
    var popup=new google.maps.InfoWindow({
        content: text<?php echo $el?>
    });
     
    var marker = new google.maps.Marker({
      position: myLatlng<?php echo $el?>, 
      map: map,
      html: text<?php echo $el?>,
      url: 'javacsript: void()',
      icon : '<?php echo $baseurl.$le->icon_map;?>'      
      //title:"<?php echo $le->placeName?>"
    }); 
      
    google.maps.event.addListener(marker, 'click', function() {
        $(".orverlay").css('display', 'block');
        //alert("Vui lòng chọn địa điểm từ popup");
        setTimeout(function()
        {
            $(".orverlay").css("display", "none");
        },100);
    }); 
    
    google.maps.event.addListener(marker, 'mouseover', function(e) {
    
        popup.setContent(this.html);
        popup.open(map, this);
    });
    google.maps.event.addListener(marker, 'mouseout', function(e) {
        
        popup.setContent(this.html);
        //popup.close(map, this);
    });
    <?php endforeach;?> 
}

</script>

<div class="inside">
   <div class="contentPanel full dashboard maps">
      <div class='pages' id='design' style="height: 100%;">
        <div id="div_id" style="width: 100%;height: 100%;"></div>
      </div>
   </div>
</div>
<?php
sleep(1);
?>
<style type="text/css">
    #div_id{
        line-height: 20px;
    }
    #div_id img{
        max-width: none;
    }
</style>